{layout name="public/layout" /}
{include file='yxnavbar'}


<style>
    .we7-form .help-block, form .help-block {
        color: #98999a;
        padding-top: 10px;
        margin-top: 0;
        margin-bottom: 0;
        line-height: 15px;
    }
</style>
<script  type="text/javascript">
    function jump(){
        layer.msg('正在准备下载');
    }
</script>
<div class="main">
    <ul class="nav nav-tabs">
        <li {if $op =='display'}class="active"{/if}><a href="{php echo createWebUrl('complain', array('themeid'=>$themeid));}">列表</a></li>
        {if $op =='reply'}
        <li class="active"><a href="{php echo createWebUrl('complain', array('themeid'=>$themeid,'op'=>'reply', 'id' => $id));}">详情</a></li>
        {/if}
        <div class="form-group">
            <form id = "myform2" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="{$do}" />
                <input type="hidden" name="op" value="display" />
                {if count($themelist)>1 }
                <div class="col-sm-3 control-label" style="float: right;">
                    <select onchange="submitForm();" class="form-control" name="themeid">
                        {loop $themelist $row}
                        <option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
                        {/loop}
                    </select>
                </div>
                <script type="text/javascript">
                    function submitForm(){
                        var form = document.getElementById("myform2");
                        form.submit();
                    }
                </script>
                {/if}
            </form>
        </div>
    </ul>

</div>
{if $op =='reply'}
<form class="form-horizontal form" action="" method="post" action="./index.php" enctype="multipart/form-data">
    <div class="col-sm-12 col-xs-12">
        <div class="panel panel-default">
            <div class="panel-heading" style="font-size: 22px;">
                {if $complain['status']==1}
                待处理
                {elseif $complain['status']==2}
                处理中
                {elseif $complain['status']==3}
                投诉已完结
                {/if}
            </div>
        </div>
    </div>

    <div class="col-sm-5 col-xs-12">
        <div class="panel panel-default">
            <div class="panel-heading">投诉内容</div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">投诉原因</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">{$complain['type']}</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">投诉编号</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">{php echo $server . $complain['id'];}</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">投诉者信息</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block"><img src="{php echo tomedia($complain['avatar']);}" width="28" style="border-radius: 3px;"><br>{$complain['nickname']}</span>
                    </div>
                </div>
                {if !empty($complain['order_id'])}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">定单编号</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">{php echo 9000+$complain['order_id'];}</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">定单信息</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">姓名：{$complain['order_username']}<br>
                        电话：{$complain['order_mobile']}<br>
                        金额：{$complain['order_fee']}</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">定单状态</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">
                                {if $complain['paystatus']==0}
                  <span class="label label-warning">未支付</span>
                  {elseif $complain['paystatus']==1}
                  <span class="label label-success">已支付</span>
                  {elseif $complain['paystatus']==2}
                  <span class="label label-primary">已核销</span>
                  {elseif $complain['paystatus']==-1}
                  <span class="label label-danger">已退款</span>
                  {elseif $complain['paystatus']==-2}
                  <span class="label label-danger">虚拟定单</span>
                  {elseif $complain['paystatus']==3}
                  <span class="label label-info">线下定单</span>
                {/if}</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 control-label">付款时间</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">{$complain['paytime']}</span>
                    </div>
                </div>
                {/if}
            </div>
        </div>
    </div>
    <div class="col-sm-7 col-xs-12">
        <div class="panel panel-default">
            <div class="panel-heading">处理进度</div>
            <div class="panel-body">
<!--                -->
<!--                用户认可处理结果，投诉已完结-->
                {if $complain['status']==2 && $complain['reply_info'][0]['type']!='用户回复'}
                <div class="form-group">
                    <label class="col-xs-12 control-label" style="text-align: center;font-weight: bold;color:#999999;">{$complain[0]['type']}商家已回复，等待客户确认</label>
                </div>
                {/if}

                {loop $complain['reply_info'] $row}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label" style="font-weight: bold">{$row['type']}</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">{$row['reply']}</span>
                        <span class="help-block">{$row['time']}{if $_G['isSuperAdmin']} 操作：{$row['opuser']}{/if}</span>
                    </div>
                </div>
                {/loop}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label" style="font-weight: bold">{php echo $complain['type']=='申请退款'?'用户申请退款':'用户发起投诉';}</label>
                    <div class="col-sm-8 col-xs-12">
                        <span class="help-block">{$complain['content']}</span>
                        <span class="help-block">{$complain['created_at']}</span>
                    </div>
                </div>
            </div>

        </div>
        {if $complain['status']!=3}
        <div class="panel panel-default">
            <div class="panel-heading">回复信息</div>
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-xs-12">
                        <textarea rows="5" cols="50" class="form-control"  name="reply_txt"></textarea>
                    </div>
                </div>
                <div class="form-group" style="margin-bottom:0px;">
                    <div class="col-sm-3">
                        <input name="submit" id="btn_submit" type="submit" value="提交" class="btn btn-primary col-lg-12">
                    </div>
                    {if $_G['isSuperAdmin']}
                    <div class="col-sm-3">
                        <input name="submit" id="btn_submit" type="submit" value="关闭会话" class="btn btn-success col-lg-12">
                    </div>
                    {/if}

                    {if $complain['paystatus']==1}
                    <div class="col-sm-3">
                        <a href="{php echo createWebUrl('complain', array('op' => 'refund','themeid'=>$themeid,'complanID'=>$complain['id'], 'id' => $complain['order_id']));}" class="btn btn-warning btn-sm" onclick="if(!confirm('当客户拍错或退单时可以直接退回原账户，确定退款吗')) return false;"  title="退款" data-toggle="tooltip" data-placement="top"><i class="fa fa-chain-broken"> </i>退款</a>
                    </div>
                    {/if}
                    <input type="hidden" name="__token__" value="{$Request.token}" />
                    <input type="hidden" name="themeid" value="{$themeid}" />
                    <input type="hidden" name="c" value="site" />
                    <input type="hidden" name="a" value="entry" />
                    <input type="hidden" name="m" value="{$_P['m']}" />
                    <input type="hidden" name="do" value="complain" />
                    <input type="hidden" name="op" value="reply" />
                </div>
            </div>
        </div>
        {/if}
    </div>
</form>
{else}
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$total}</div>
        <div class="panel-body">
            <form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="complain" />
                <input type="hidden" name="themeid" value="{$themeid}" />
                <input type="hidden" name="status" value="{$status}" />
                {if !empty($type_list)}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-1 control-label">投诉原因</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $type_list $row}
                            <a href="{php echo createWebUrl('complain',array('themeid'=>$themeid,'op'=>'display','type'=>$row['title']));}" class="btn {if $type == $row['title']}btn-primary{else}btn-default{/if}">
                                {$row['title']}
                                <span style="color: #ff0000">{$row['total']}</span>
                            </a>
                            {/loop}
                        </div>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-1 control-label">投诉状态</label>
                    <div class="col-sm-9 col-lg-9 col-md-9 col-xs-6">
                        <div class="col-xs-11 col-sm-9 col-md-9">
                            <div class="btn-group">
                                {loop $status_list $row}
                                <a href="{php echo createWebUrl('complain',array('themeid'=>$themeid,'op'=>'display','status'=>$row['status']));}" class="btn {if $status == $row['status']}btn-primary{else}btn-default{/if}">
                                    {$row['title']}
                                    <span style="color: #ff0000">{$row['total']}</span>
                                </a>
                                {/loop}
                            </div>

                        </div>
                    </div>
                </div>

                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-2 col-md-1 control-label">关键字</label>
                    <div class="col-sm-3 col-xs-3 col-md-3">
                        <input class="form-control" name="search_data" placeholder="输入微信昵称、手机号、投诉原因、投诉内容" type="text" value="{$_P['search_data']}">
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                    <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2">
                        {if $total<=5000}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出记录EXCEL">
                        {else}
                        <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出记录EXCEL(1-5000条)">
                        {/if}
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th style="width:80px;">序号</th>
                    <th style="width:120px;">投诉者</th>
                    <th style="width:120px;">投诉原因</th>
                    <th style="min-width:200px;">投诉内容</th>
                    <th style="width:180px;">定单信息</th>
                    <th style="width:100px;">定单状态</th>
                    <th style="width:180px;">所属员工</th>
                    <th style="width:100px;">状态</th>
                    <th style="width:100px;">投诉时间</th>
                    <th style="width:100px;">处理时间</th>
                    <th style="width:100px; text-align:right;">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $list $item}
                <tr>
                    <td>{php echo $server . $item['id'];}</td>
                    <td><img src="{$item['avatar']}" width="28px" style="border-radius: 3px;">
                        <br>{$item['nickname']}
                        <br>{$item['mobile']}
                    </td>
                    <td>{$item['type']}</td>
                    <td>{$item['content']}</td>
                    <td>
                        定单号：{php echo $item['order_id']+9000;}<br>
                        姓名：{$item['order_username']}<br>
                        电话：{$item['order_mobile']}<br>
                        金额：{$item['order_fee']}<br>
                        付款时间：{php echo mb_substr($item['paytime'],0,10,'utf-8');}
                    </td>
                    <td>
                        {if $item['paystatus']==0}
                        <span class="label label-warning">未支付</span>
                        {elseif $item['paystatus']==1}
                        <span class="label label-success">已支付</span>
                        {elseif $item['paystatus']==2}
                        <span class="label label-primary">已核销</span>
                        {elseif $item['paystatus']==-1}
                        <span class="label label-danger">已退款</span>
                        {elseif $item['paystatus']==-2}
                        <span class="label label-danger">虚拟定单</span>
                        {elseif $item['paystatus']==3}
                        <span class="label label-info">线下定单</span>
                        {/if}
                    </td>
                    <td>{$item['workername']}<br>{$item['teamname']}<br>{$item['companyname']}</td>
                    <td>
                        {if $item['status']==1}
                        <span class="label label-warning">待处理</span>
                        {elseif $item['status']==2}
                        <span class="label label-info">处理中</span>
                        {elseif $item['status']==3}
                        <span class="label label-success">已完结</span>
                        {/if}
                    </td>
                    <td>{$item['created_at']}</td>
                    <td>{if $item['status']==2}
                            {$item['worker_info']}<br>
                            {$item['updated_at']}
                        {/if}
                    </td>
                    <td style="text-align:right;">
                        <a class="btn btn-primary btn-sm" href="{php echo createWebUrl('complain', array('themeid'=>$themeid,'op'=>'reply', 'id' => $item['id']));}">详情</a>
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        {$pager}
    </div>
{/if}

